<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="${pageContext.request.contextPath }/bootstrapStyle/img/favicon.ico">
<link href="${pageContext.request.contextPath }/bootstrapStyle/css/style.min.css?v=4.0.0" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrapStyle/css/animate.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrapStyle/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
<link href="${pageContext.request.contextPath}/bootstrapStyle/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrapStyle/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/bootstrapStyle/css/jquery-confirm.css"/>
<title>医院-我的订单</title>
</head>
<body>
	<!-- <div class="panel panel-default">
	    <div class="panel-body form-group" style="margin-bottom:0px;">
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">姓名：</label>
	        <div class="col-sm-2">
	            <input type="text" class="form-control" name="Name" id="search_name"/>
	        </div>
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">手机号：</label>
	        <div class="col-sm-2">
	            <input type="text" class="form-control" name="Name" id="search_tel"/>
	        </div>
	        <div class="col-sm-1 col-sm-offset-4">
	            <button class="btn btn-primary" id="search_btn">查询</button>
	        </div>
	     </div>
	</div> -->
	<!-- 我的订单详情页 -->
	<div class="modal inmodal fade" id="detailsModal" tabindex="-1" role="dialog"  aria-hidden="true">
    	<div class="modal-dialog modal-lg" style="width:800px;">
        	<div class="modal-content">
            	<div class="modal-header">
                	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">我的订单详情</h4>
               	</div>
                <div class="modal-body">
                	<h2>订单详情！</h2>
                </div>
				<div class="modal-footer">
                	<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
           		</div>
           	</div>
        </div>
	</div>
	<!-- 动态加载table -->
	<table id="mytab" class="table table-hover"></table>
	
	<!-- 隐藏的modal，主要是输入金额，显示预选的部门以及 -->
	<div class="modal inmodal fade" id="myDepositModal" tabindex="-1" role="dialog"  aria-hidden="true">
    	<div class="modal-dialog modal-lg">
        	<div class="modal-content">
            	<div class="modal-header">
                	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">设置押金</h4>
               	</div>
                <div class="modal-body">
                	<input type="hidden" id="userorderid" />
                	<div class="form-group">
                		<label>押金金额：</label>
                		<input type="text" min="1" onkeyup="num(this)" id="userorderdeposit" class="userorderdeposit form-control" style="width:300px;" placeholder="请输入押金金额">
                	</div>
                	<div class="form-group">
                		<label>预约床位科室：</label>
                		<h4>一级科室：<a style="color:red" title="点击查看该部门剩余床位" id="fdeptshow"></a>&nbsp&nbsp二级科室：<a style="color:red" title="点击查看该部门剩余床位" id="sdeptshow"></a></h4>
                		<input type="hidden" id="FDept"/><input type="hidden" id="SDept"/><input type="hidden" id="berthnumber"/>
                		<a style="color:red;font-size: 15px;" href="javscript:;" data-toggle="modal" data-target="#myDeptModal" onclick="ChangeDept()">选择部门?</a>
                	</div>
                </div>
				<div class="modal-footer">
                	<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                	<button type="button" class="btn btn-primary" onclick="myDepositModalSubmit()" id="myDepositModalSubmit">提交</button>
           		</div>
           	</div>
        </div>
	</div>
	<div class="modal inmodal fade" id="myDeptModal" tabindex="-1" role="dialog"  aria-hidden="true">
    	<div class="modal-dialog modal-lg">
        	<div class="modal-content">
            	<div class="modal-header">
                	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">选择科室</h4>
               	</div>
                <div class="modal-body">
                	<div class="form-group draggable">
						<label class="control-label">科室选择*</label>
						<select class="form-control" name="One_level_dept" id="One_level_dept" required="" aria-required="true" onchange="getDept()">
							<option value="-1">------请选择一级科室------</option>
						</select>
						<br/>
						<select class="form-control" name="Two_level_dept" id="Two_level_dept" required="" aria-required="true">
							<option value="-1">------请选择二级科室------</option>
						</select>
					</div>
                </div>
				<div class="modal-footer">
                	<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                	<button type="button" class="btn btn-primary" onclick="myDeptModalSubmit()" id="myDeptModalSubmit">保存</button>
           		</div>
           	</div>
        </div>
	</div>
	<div class="modal inmodal fade" id="AddDepositModal" tabindex="-1" role="dialog"  aria-hidden="true">
    	<div class="modal-dialog modal-lg">
        	<div class="modal-content">
            	<div class="modal-header">
                	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">增加押金</h4>
               	</div>
                <div class="modal-body">
                	<input type="hidden" id="adduserorderid"/>
                	<div class="form-group">
                		<label>增加押金金额：</label>
                		<input type="text" onkeyup="num(this)" min="1" id="adduserorderdeposit" class="adduserorderdeposit form-control" style="width:300px;" placeholder="请输入增加的押金金额">
                	</div>
                </div>
				<div class="modal-footer">
                	<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                	<button type="button" class="btn btn-primary" onclick="AddDepositSubmit()" id="AddDepositSubmit">提交</button>
           		</div>
           	</div>
        </div>
	</div>
	<!-- <div id="toolbar" class="btn-group pull-right" style="margin-right: 20px;">
     <button id="btn_edit" type="button" class="btn btn-default" style="display: none; border-radius: 0">
         <span class="glyphicon glyphicon-pencil" aria-hidden="true" ></span>修改
     </button>
      <button id="btn_delete" type="button" class="btn btn-default" style="display: none;">
          <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
      </button>
      <button id="btn_add" type="button" class="btn btn-default">
          <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
      </button>
 	</div> -->
    <script src="${pageContext.request.contextPath }/bootstrapStyle/js/jquery.min.js?v=2.1.4"></script>
    <script src="${pageContext.request.contextPath }/bootstrapStyle/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrapStyle/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrapStyle/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrapStyle/js/jquery-confirm.js"></script>
    <script>
  	//根据窗口调整表格高度
    $(window).resize(function() {
        $('#mytab').bootstrapTable('resetView', {
            height: tableHeight()
        })
    })
    //查询按钮事件
    $('#search_btn').click(function(){
        $('#mytab').bootstrapTable('refresh');
    })
    //tableHeight函数
    function tableHeight(){
        //可以根据自己页面情况进行调整
        return $(window).height() -210;
    }
  	function refreshTab(){
  		$('#mytab').bootstrapTable('refresh');
  	}
	//生成用户数据
    $('#mytab').bootstrapTable({
        method: 'get',
        contentType: "application/x-www-form-urlencoded",//必须要有！！！！
        url:"${pageContext.request.contextPath}/Main/OrderMan/OrderAjax.action",//要请求数据的文件路径
        height:tableHeight(),//高度调整
        striped: true, //是否显示行间隔色
        dataField: "rows",//bootstrap table 可以前端分页也可以后端分页，这里
        //我们使用的是后端分页，后端分页时需返回含有total：总记录数,这个键值好像是固定的  
        //rows： 记录集合 键值可以修改  dataField 自己定义成自己想要的就好
        pageNumber: 1, //初始化加载第一页，默认第一页
        pagination:true,//是否分页
        queryParamsType:'limit',//查询参数组织方式
        queryParams:function(params) {//自定义参数，这里的参数是传给后台的，我这是是分页用的    
            return {//这里的params是table提供的    
                offset : params.offset,//从数据库第几条记录开始    
                limit : params.limit,
                type:null
            //找多少条    
            };},//请求服务器时所传的参数
        sidePagination:'server',//指定服务器端分页
        pageSize:10,//单页记录数
        pageList:[1,5,10,30,50,100],//分页步进值
        showRefresh:true,//刷新按钮
        showColumns:true,
        clickToSelect: true,//是否启用点击选中行
        toolbarAlign:'right',//工具栏对齐方式
        buttonsAlign:'right',//按钮对齐方式
        toolbar:'#toolbar',//指定工作栏
        columns:[
            {
                title:'全选',
                field:'select',
                //复选框
                checkbox:true,
                width:25,
                align:'center',
                valign:'middle'
            },
            {
                title:'订单ID',
                field:'userorderid',
                visible:true
            },
            {
                title:'病人姓名',
                field:'familyname',
                sortable:true,
                formatter:nullChange
            },
            {
                title:'住院一级部门',
                field:'userorderhospprimarydept',
                sortable:true,
                formatter:nullChange
            },
            {
                title:'住院二级部门',
                field:'userorderhospseconddept',
                sortable:true,
                formatter:nullChange
            },
            {
                title:'预约医院时间',
                field:'userorderchosehosptime',
                sortable:true,
                formatter:nullChange
            },
            {
                title:'预约医生',
                field:'docname',
                sortable:true,
                formatter:nullChange
            },
            {
                title:'当前需要缴纳押金',
                field:'userorderdeposit',
                sortable:true,
                formatter:nullChange
            },
            {
                title:'已缴纳的押金总额',
                field:'userordertotaldeposit',
                sortable:true,
                formatter:nullChange
            },
            {
                title:'住院实际产生费用',
                field:'userorderhprice',
                sortable:true,
                formatter:nullChange
            },
            {
                title:'住院情况',
                field:'actualhospitalizationstatename',
                sortable:true,
                formatter:nullChange
            },
            {
                title:'状态',
                field:'userorderstatename',
                align:'center',
                //列数据格式化
                //formatter:operateFormatter
            },
            {
                title:'操作',
                field:'userorderstateid',
                align:'center',
                //列数据格式化
                formatter:operateConfirm
            }
        ],
        locale:'zh-CN',//中文支持,
        responseHandler:function(rows){
            //在ajax获取到数据，渲染表格之前，修改数据源
            return rows;
        }
    })
    //三个参数，value代表该列的值
    /* function operateFormatter(value,row,index){
        if(value==2){
            return '<i class="fa fa-lock" style="color:red"></i>'
        }else if(value==1){
            return '<i class="fa fa-unlock" style="color:green"></i>'
        }else{
            return '<i class="fa fa-unlock" style="color:green">'
        }
    } */
    //对所有空值规格化，null-》未填写
    function nullChange(value,row,index){
		if(value=='null' || value==''){
			return '未填写'
		}else{
			return value;
		}
	}
    
	//操作序列规则化
	function operateConfirm(value,row,index){
		var orderid = row.userorderid;
		var fdept = "'"+row.userorderhospprimarydept+"'";
		var sdept = "'"+row.userorderhospseconddept+"'";
		var totalprice = ""+row.userordertotaldeposit+"";
		if(value==5 && totalprice=='0.0'){
			return '<button class="btn btn-info" style="height:30px" onclick="Details('+orderid+')">详情</button>&nbsp;&nbsp;<button class="btn btn-primary" style="height:30px" onclick="Confirm('+orderid+','+fdept+','+sdept+')"  data-toggle="modal" data-target="#myDepositModal" >输入押金</button>&nbsp;&nbsp;<button class="btn btn-danger" style="height:30px" id="cancel'+orderid+'" onclick="Cancel('+orderid+')">取消</button>';
	    }else if(value==5 && totalprice!='0.0'){
	    	return '<button class="btn btn-info" style="height:30px" onclick="Details('+orderid+')">详情</button>&nbsp;&nbsp;<button class="btn btn-primary" style="height:30px" onclick="Confirm('+orderid+','+fdept+','+sdept+')"  data-toggle="modal" data-target="#myDepositModal" >输入押金</button>';
	    }else if(value==7){
		    return '<button class="btn btn-info" style="height:30px" onclick="Details('+orderid+')">详情</button>&nbsp;&nbsp;<button class="btn btn-warning" style="height:30px" data-toggle="modal" data-target="#AddDepositModal" onclick="AddDeposit('+orderid+')">增加押金</button>';
	    }else if((value==6 || value==1 || value==2 || value==3 || value==4)&&totalprice=='0.0'){
	    	return '<button class="btn btn-info" style="height:30px" onclick="Details('+orderid+')">详情</button>&nbsp;&nbsp;<button class="btn btn-danger" style="height:30px" id="cancel'+orderid+'" onclick="Cancel('+orderid+')">取消</button>';
	    }else{
	    	return '<button class="btn btn-info" style="height:30px" onclick="Details('+orderid+')">详情</button>';
	    }
	}
    //请求服务数据时所传参数
    /* function queryParams(params){
        return{
            //每页多少条数据
            pageSize: params.limit,
            //请求第几页
            pageIndex:params.offset,
            //Name:$('#search_name').val(),
            //Tel:$('#search_tel').val()
        }
    } */
    //修改null为空值
    function AbandonNull(value){
    	if(value=='null'){
    		return '';
    	}else{
    		return value;
    	}
    }
    //点击操作列的“输入押金”,将订单id赋值到hidden里
    function Confirm(orderid,fdept,sdept){
    	//初始化hidden，清空hidden的值
		$("#userorderid").val('');$("#berthnumber").val('');
    	$("#FDept").val('');$("#SDept").val('');
    	$("#fdeptshow").html('');$("#sdeptshow").html('');
    	
    	$("#userorderid").val(orderid);
    	CheckBerthNumber(fdept,sdept);   	
    }
     function CheckBerthNumber(fdept,sdept){
    	var param="userorderhospprimarydept="+fdept+"&userorderhospseconddept="+sdept;
    	$.ajax({
    		type:"post",
    		url: "${pageContext.request.contextPath}/Main/OrderMan/CheckDeptEmpty.action",
            //contentType:"application/json;charset=utf-8",
    		async: true,
            data:param,
            success: function (data) {
            	//$.alert("所选科室床位数还有:  "+data.number+"  个");
            	if(AbandonNull(sdept)==''){
            		$("#FDept").val(AbandonNull(fdept));$("#SDept").val(AbandonNull(sdept));
                	$("#fdeptshow").html(AbandonNull(fdept)+'（该科室床位数量为'+data+'）');$("#sdeptshow").html(AbandonNull(sdept));
            	}else{
            		$("#FDept").val(AbandonNull(fdept));$("#SDept").val(AbandonNull(sdept));
                	$("#fdeptshow").html(AbandonNull(fdept));$("#sdeptshow").html(AbandonNull(sdept)+'（该科室床位数量为'+data+'）');
            	}
            	$("#berthnumber").val(data);
            },error:function(request){
            	$.alert('failed to link,please try a few minutes later!');
            }
    	})
    }
    //点击操作列的“拒绝”,拒绝这个订单
    function Cancel(orderid){
    	//alert("拒绝-》userorderid："+orderid+">>>>>>>");
    	$.confirm({
		    title: '提示!',
		    content: '你确定拒绝该订单？',
		    type: 'blue',
		    typeAnimated: true,
		    buttons: {
		    	确定: function () {
		    		$("#cancel"+orderid).html('<i class="fa fa-spinner fa-spin"></i>处理中...');
		    		$("#cancel"+orderid).prop('disabled',true);
		    		$.ajax({
		        		type:'post',
		        		url:"${pageContext.request.contextPath}/Main/OrderMan/RefuseOrder.action",
		        		data:"userorderid="+orderid,
		        		async: true,
		        		success:function(data){
		        			$("#cancel"+orderid).html('取消');
				    		$("#cancel"+orderid).prop('disabled',false);
		        			$.alert(data.msg);
		        			if(data.code==100){
		        				refreshTab();
		        			}
		        		},error:function(request){
		        			$.alert("向服务器请求失败！");
		        			$("#cancel"+orderid).html('取消');
				    		$("#cancel"+orderid).prop('disabled',false);
		        		}
		        	})
		    	},
				取消: function () {},
		    }	
		});
    }
    //点击modal里的改变部门a标签，弹出选择部门的modal2
    function ChangeDept(){
    	LoadFirstDept();
    	var userorderid = $("#userorderid").val();
    	//$("#deptshow").html("123456");
    }
    //一级科室加载
    function LoadFirstDept(){
    	$.ajax({  //页面首加载一级部门下拉框数据
            type: "post",  
            url: "${pageContext.request.contextPath}/Main/doctor/getHospitalDept.action",
            //contentType:"application/json;charset=utf-8",
    		async: true,
            //data:'{"hospdeptfatherid=0":"'+0+'"}',
            data:"hospdeptfatherid=0",
            success: function (data) {
            	var datalist = data.list;
                for (var i = 0; i < datalist.length; i++) {  
                    $('#One_level_dept').append("<option value='" + datalist[i].hospdeptid + "' >" + datalist[i].hospdeptname + "</option>");  
                }  
            },  
            error: function () {  
                $.alert("加载一级部门失败!!!");  
            }  
        });
    }
    //在一级科室加载后，点击一级科室后加载二级科室
    function getDept(){
		var One_level_dept = $("#One_level_dept").val();
		if(One_level_dept==-1){
            $("#Two_level_dept").empty();
            $('#Two_level_dept').append("<option value='-1' selected='selected' >"+'------请选择二级科室------'+"</option>");  
		}else{
			$("#Two_level_dept").empty();
			$.ajax({  //页面首加载一级部门下拉框数据
                type: "post",  
                url: "${pageContext.request.contextPath}/Main/doctor/getHospitalDept.action",
                //contentType:"application/json;charset=utf-8",
        		async: true,
                data:"hospdeptfatherid="+One_level_dept,
                success: function (data) {
                	var datalist = data.list;
                    $('#Two_level_dept').append("<option value='-1' selected='selected' >"+'------请选择二级科室------'+"</option>");  
                    for (var i = 0; i < datalist.length; i++) {  
                        $('#Two_level_dept').append("<option value='" + datalist[i].hospdeptid + "' >" + datalist[i].hospdeptname + "</option>");  
                    }  
                },  
                error: function () {  
                    $.alert("加载一级部门失败!!!");  
                }  
            });
		}
	}
    
    //点击myDepositModal中的保存按钮
    function myDepositModalSubmit(){
    	var userorderid=$('#userorderid').val();
    	var userorderdeposit=$('#userorderdeposit').val();
    	var userorderhospprimarydept = $('#FDept').val();
    	var userorderhospseconddept = $('#SDept').val();
    	var berthnumber = $('#berthnumber').val();
    	if(berthnumber=='' || berthnumber==0){
    		$.alert("所选科室床位数不够，重新选择科室！");
    		return false;
    	}
    	if(!userorderdeposit && userorderdeposit<=0){
    		$.alert("填写押金，并大于零！！");
    		return false;
    	}
    	$.confirm({
		    title: '提示!',
		    content: '是否确认该订单,病人会根据您填写的押金选择是否住院？',
		    type: 'blue',
		    typeAnimated: true,
		    buttons: {
		    	确定: function () {
		    		$("#myDepositModalSubmit").html('<i class="fa fa-spinner fa-spin"></i>处理中...');
		    		$("#myDepositModalSubmit").prop('disabled',true);
		    		//向服务器发送医院确认订单操作！
		        	$.ajax({
		        		type:"post",
		        		url:"${pageContext.request.contextPath}/Main/OrderMan/AccepteOrder.action",
		        		async: true,
		                data:"userorderid="+userorderid+"&userorderdeposit="+userorderdeposit+"&userorderhospprimarydept="+userorderhospprimarydept+"&userorderhospseconddept="+userorderhospseconddept,
		               	success:function(data){
		               		$("#myDepositModalSubmit").html('提交');
				    		$("#myDepositModalSubmit").prop('disabled',false);
		               		$.alert(data.msg);
		               		if(data.code==100){
		               			$('#myDepositModal').modal('hide');
		               			refreshTab();
		               		}
		               	},error:function(request){
		               		alert("请求出错了！");
		               		$("#myDepositModalSubmit").html('提交');
				    		$("#myDepositModalSubmit").prop('disabled',false);
		               	}
		        	})
		    	},
				取消: function () {$('#myDepositModal').modal('hide');},
		    }	
		});
    }
    //点击myDeptModal中的保存按钮
    function myDeptModalSubmit(){
    	var One_level_dept = $('#One_level_dept').find("option:selected").text();
    	var Two_level_dept = $('#Two_level_dept').find("option:selected").text();
    	if($('#One_level_dept').val()==-1){
    		$.alert("一级科室必须选择");
    		return false;
    	}
    	$("#myDeptModalSubmit").html('<i class="fa fa-spinner fa-spin"></i>处理中...');
		$("#myDeptModalSubmit").prop('disabled',true);
    	BerthIsEmpty(One_level_dept,Two_level_dept);
    	//alert(One_level_dept+":"+Two_level_dept);
    	
    }
    //检查科室是否有床位
    function BerthIsEmpty(One_level_dept,Two_level_dept){
    	var hospdeptname='';
		if($('#Two_level_dept').val()==-1){
			Two_level_dept='';
			hospdeptname=One_level_dept;
    	}else{
    		hospdeptname=Two_level_dept;
    	}
    	if(hospdeptname==null){
    		$.alert('请选择一个部门！');
    		return false;
    	}
    	var param="userorderhospprimarydept="+One_level_dept+"&userorderhospseconddept="+Two_level_dept;
    	$.ajax({
    		type:"post",
    		url: "${pageContext.request.contextPath}/Main/OrderMan/CheckDeptEmpty.action",
            //contentType:"application/json;charset=utf-8",
    		async: true,
            data:param,
            success: function (data) {
            	$("#myDeptModalSubmit").html('提交');
	    		$("#myDeptModalSubmit").prop('disabled',false);
            	$.alert("所选科室床位还有  :"+data+" 个");
            	if(data>0){
            		if($('#Two_level_dept').val()==-1){
                		$("#FDept").val(AbandonNull(One_level_dept));$("#SDept").val(AbandonNull(Two_level_dept));
                    	$("#fdeptshow").html(AbandonNull(One_level_dept)+'（该科室床位数量为'+data+'）');$("#sdeptshow").html(AbandonNull(Two_level_dept));
                	}else{
                		$("#FDept").val(AbandonNull(One_level_dept));$("#SDept").val(AbandonNull(Two_level_dept));
                    	$("#fdeptshow").html(AbandonNull(One_level_dept));$("#sdeptshow").html(AbandonNull(Two_level_dept)+'（该科室床位数量为'+data+'）');
                	}
                	$("#berthnumber").val(data);
                	$('#myDeptModal').modal('hide');
            	}
            },error:function(request){
            	$.alert('failed to link,please try a few minutes later!');
            	$("#myDeptModalSubmit").html('提交');
	    		$("#myDeptModalSubmit").prop('disabled',false);
            }
    	})
    }
    
    function AddDeposit(orderid){
    	alert(orderid);
    	$("#adduserorderid").val(orderid);
    }
    function AddDepositSubmit(){
    	var orderid = $("#adduserorderid").val();
    	var Deposit = $("#adduserorderdeposit").val();
    	if(Deposit==''){
    		$.alert("增加的押金不可为空！");
    		return false;
    	}
    	$.confirm({
		    title: '提示!',
		    content: '是否确认增加押金？',
		    type: 'blue',
		    typeAnimated: true,
		    buttons: {
		    	确定: function () {
		    		$("#AddDepositSubmit").html('<i class="fa fa-spinner fa-spin"></i>处理中...');
		    		$("#AddDepositSubmit").prop('disabled',true);
		    		//向服务器发送医院确认订单操作！
		        	$.ajax({
		        		type:"post",
		        		url:"${pageContext.request.contextPath}/Main/OrderMan/AddDeposit.action",
		        		async: true,
		                data:"userorderid="+orderid+"&userorderdeposit="+Deposit,
		               	success:function(data){
		               		$("#AddDepositSubmit").html('提交');
				    		$("#AddDepositSubmit").prop('disabled',false);
		               		$.alert(data.msg);
		               		if(data.code==100){
		               			$('#AddDepositModal').modal('hide');
		               			refreshTab();
		               		}
		               	},error:function(request){
		               		alert("请求出错了！");
		               		$("#AddDepositSubmit").html('提交');
				    		$("#AddDepositSubmit").prop('disabled',false);
		               	}
		        	})
		    	},
				取消: function () {$('#AddDepositModal').modal('hide');},
		    }	
		});
    }
    function Details(orderid){
    	//alert(orderid);
    	$("#detailsModal").modal("show");
    }
    function num(obj){
    	obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
    	obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字
    	obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个, 清除多余的
    	obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
    	obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数
    }
	</script>
</body>
</html>